<template>
  <div class="container">
    <div id="login" class="wrap login-wrap">
      <div class="form">
        <span class="title">用户登录</span>
        <div class="item">
          <input v-model="formData.userName" placeholder="用户名" name="userName" />
        </div>
        <div class="item">
          <input v-model="formData.userPass" placeholder="用户密码" name="userPass" type="password" />
        </div>
        <div class="opt">
          <button @click="onLogin()">登录</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import api from "../apis/user";
export default {
  data() {
    return {
      formData: {
        userName: "hxl",
        userPass: "hxl495594@"
      }
    };
  },
  methods: {
    onLogin() {
      api.login(this.formData).then(res => {
        if (res.code == 0) {
          this.$router.push({ path: "/" });
          return
        }
         this.$toast(
          "提示",
          "用户名或密码错误",
          i => {
          
          }
        );
      });
      return true;
    }
  }
};
</script>

<style lang="less" scoped>
@import url("../style/less/base.less");
@import url("../style/less/login.less");
</style>